import request from '@/utils/request'

export function fetchList(query) {
  return request({
    url: '/v2/backend/article/list',
    method: 'get',
    params: { page: query.page - 1, size: query.size }
  })
}

export function fetchArticleTypeList() {
  return request({
    url: '/v2/backend/articleType/list',
    method: 'get'
  })
}

export function fetchListCount(query) {
  return request({
    url: '/v2/backend/article/count',
    method: 'get',
    params: query
  })
}

export function fetchArticleDetail(articleId) {
  return request({
    url: '/v2/backend/article/' + articleId,
    method: 'get'
  })
}

export function fetchArticleContent(articleContentId) {
  return request({
    url: '/v2/backend/articleContent/' + articleContentId,
    method: 'get'
  })
}

export function deleteArticle(articleId) {
  return request({
    url: '/v2/backend/article/' + articleId,
    method: 'delete'
  })
}

export function saveArticle(data) {
  return request({
    url: '/v2/backend/article',
    method: 'post',
    data
  })
}

export function saveArticleContent(data) {
  return request({
    url: '/v2/backend/articleContent',
    method: 'post',
    data
  })
}

export function uploadImage(data) {
  return request({
    url: '/v2/editor/image',
    method: 'post',
    data
  })
}

